home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / bg_public.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  14.3 KB  |  566 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. // bg_public.h -- definitions shared by both the server game and client game modules
  4.  
  5. // because games can change separately from the main system version, we need a
  6. // second version that must match between game and cgame
  7. #define    GAME_VERSION        "baseq3-1"
  8.  
  9. #define    DEFAULT_GRAVITY        800
  10. #define    GIB_HEALTH            -40
  11. #define    ARMOR_PROTECTION    0.66
  12.  
  13. #define    MAX_ITEMS            256
  14.  
  15. #define    RANK_TIED_FLAG        0x4000
  16.  
  17. #define DEFAULT_SHOTGUN_SPREAD    700
  18. #define DEFAULT_SHOTGUN_COUNT    11
  19.  
  20. #define    ITEM_RADIUS            15        // item sizes are needed for client side pickup detection
  21.  
  22. #define    LIGHTNING_RANGE        768
  23.  
  24. #define    SCORE_NOT_PRESENT    -9999    // for the CS_SCORES[12] when only one player is present
  25.  
  26. #define    VOTE_TIME            30000    // 30 seconds before vote times out
  27.  
  28. #define    MINS_Z                -24
  29. #define    DEFAULT_VIEWHEIGHT    26
  30. #define CROUCH_VIEWHEIGHT    12
  31. #define    DEAD_VIEWHEIGHT        -16
  32.  
  33. //
  34. // config strings are a general means of communicating variable length strings
  35. // from the server to all connected clients.
  36. //
  37.  
  38. // CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h
  39. #define    CS_MUSIC            2
  40. #define    CS_MESSAGE            3        // from the map worldspawn's message field
  41. #define    CS_MOTD                4        // g_motd string for server message of the day
  42. #define    CS_WARMUP            5        // server time when the match will be restarted
  43. #define    CS_SCORES1            6
  44. #define    CS_SCORES2            7
  45. #define CS_VOTE_TIME        8
  46. #define CS_VOTE_STRING        9
  47. #define    CS_VOTE_YES            10
  48. #define    CS_VOTE_NO            11
  49. #define    CS_GAME_VERSION        12
  50. #define    CS_LEVEL_START_TIME    13        // so the timer only shows the current level
  51. #define    CS_INTERMISSION        14        // when 1, fraglimit/timelimit has been hit and intermission will start in a second or two
  52. #define CS_FLAGSTATUS        15        // string indicating flag status in CTF
  53. #define    CS_ITEMS            27        // string of 0's and 1's that tell which items are present
  54.  
  55. #define    CS_MODELS            32
  56. #define    CS_SOUNDS            (CS_MODELS+MAX_MODELS)
  57. #define    CS_PLAYERS            (CS_SOUNDS+MAX_SOUNDS)
  58. #define CS_LOCATIONS        (CS_PLAYERS+MAX_CLIENTS)
  59.  
  60. #define CS_MAX                (CS_LOCATIONS+MAX_LOCATIONS)
  61.  
  62. #if (CS_MAX) > MAX_CONFIGSTRINGS
  63. #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
  64. #endif
  65.  
  66. typedef enum {
  67.     GT_FFA,                // free for all
  68.     GT_TOURNAMENT,        // one on one tournament
  69.     GT_SINGLE_PLAYER,    // single player tournament
  70.  
  71.     //-- team games go after this --
  72.  
  73.     GT_TEAM,            // team deathmatch
  74.     GT_CTF,                // capture the flag
  75.  
  76.     GT_MAX_GAME_TYPE
  77. } gametype_t;
  78.  
  79. typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t;
  80.  
  81. /*
  82. ===================================================================================
  83.  
  84. PMOVE MODULE
  85.  
  86. The pmove code takes a player_state_t and a usercmd_t and generates a new player_state_t
  87. and some other output data.  Used for local prediction on the client game and true
  88. movement on the server game.
  89. ===================================================================================
  90. */
  91.  
  92. typedef enum {
  93.     PM_NORMAL,        // can accelerate and turn
  94.     PM_NOCLIP,        // noclip movement
  95.     PM_SPECTATOR,    // still run into walls
  96.     PM_DEAD,        // no acceleration or turning, but free falling
  97.     PM_FREEZE,        // stuck in place with no control
  98.     PM_INTERMISSION    // no movement or status bar
  99. } pmtype_t;
  100.  
  101. typedef enum {
  102.     WEAPON_READY, 
  103.     WEAPON_RAISING,
  104.     WEAPON_DROPPING,
  105.     WEAPON_FIRING
  106. } weaponstate_t;
  107.  
  108. // pmove->pm_flags
  109. #define    PMF_DUCKED            1
  110. #define    PMF_JUMP_HELD        2
  111. #define    PMF_BACKWARDS_JUMP    8        // go into backwards land
  112. #define    PMF_BACKWARDS_RUN    16        // coast down to backwards run
  113. #define    PMF_TIME_LAND        32        // pm_time is time before rejump
  114. #define    PMF_TIME_KNOCKBACK    64        // pm_time is an air-accelerate only time
  115. #define    PMF_TIME_WATERJUMP    256        // pm_time is waterjump
  116. #define    PMF_RESPAWNED        512        // clear after attack and jump buttons come up
  117. #define    PMF_USE_ITEM_HELD    1024
  118. #define PMF_GRAPPLE_PULL    2048    // pull towards grapple location
  119. #define PMF_FOLLOW            4096    // spectate following another player
  120. #define PMF_SCOREBOARD        8192    // spectate as a scoreboard
  121.  
  122. #define    PMF_ALL_TIMES    (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK)
  123.  
  124. #define    MAXTOUCH    32
  125. typedef struct {
  126.     // state (in / out)
  127.     playerState_t    *ps;
  128.  
  129.     // command (in)
  130.     usercmd_t    cmd;
  131.     int            tracemask;            // collide against these types of surfaces
  132.     int            debugLevel;            // if set, diagnostic output will be printed
  133.     qboolean    noFootsteps;        // if the game is setup for no footsteps by the server
  134.     qboolean    gauntletHit;        // true if a gauntlet attack would actually hit something
  135.  
  136.     // results (out)
  137.     int            numtouch;
  138.     int            touchents[MAXTOUCH];
  139.  
  140.     vec3_t        mins, maxs;            // bounding box size
  141.  
  142.     int            watertype;
  143.     int            waterlevel;
  144.  
  145.     float        xyspeed;
  146.  
  147.     // callbacks to test the world
  148.     // these will be different functions during game and cgame
  149.     void        (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask );
  150.     int            (*pointcontents)( const vec3_t point, int passEntityNum );
  151. } pmove_t;
  152.  
  153. // if a full pmove isn't done on the client, you can just update the angles
  154. void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd );
  155. void Pmove (pmove_t *pmove);
  156.  
  157. //===================================================================================
  158.  
  159.  
  160. // player_state->stats[] indexes
  161. typedef enum {
  162.     STAT_HEALTH,
  163.     STAT_HOLDABLE_ITEM,
  164.     STAT_WEAPONS,                    // 16 bit fields
  165.     STAT_ARMOR,                
  166.     STAT_DEAD_YAW,                    // look this direction when dead (FIXME: get rid of?)
  167.     STAT_CLIENTS_READY,                // bit mask of clients wishing to exit the intermission (FIXME: configstring?)
  168.     STAT_MAX_HEALTH                    // health / armor limit, changable by handicap
  169. } statIndex_t;
  170.  
  171.  
  172. // player_state->persistant[] indexes
  173. // these fields are the only part of player_state that isn't
  174. // cleared on respawn
  175. typedef enum {
  176.     PERS_SCORE,                        // !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!!
  177.     PERS_HITS,                        // total points damage inflicted so damage beeps can sound on change
  178.     PERS_RANK,                
  179.     PERS_TEAM,                
  180.     PERS_SPAWN_COUNT,                // incremented every respawn
  181.     PERS_REWARD_COUNT,                // incremented for each reward sound
  182.     PERS_REWARD,                    // a reward_t
  183.     PERS_ATTACKER,                    // clientnum of last damage inflicter
  184.     PERS_KILLED,                    // count of the number of times you died
  185.     // these were added for single player awards tracking
  186.     PERS_IMPRESSIVE_COUNT,
  187.     PERS_EXCELLENT_COUNT,
  188.     PERS_GAUNTLET_FRAG_COUNT,
  189.     PERS_ACCURACY_SHOTS,
  190.     PERS_ACCURACY_HITS
  191. } persEnum_t;
  192.  
  193.  
  194. // entityState_t->eFlags
  195. #define    EF_DEAD                0x00000001        // don't draw a foe marker over players with EF_DEAD
  196. #define    EF_TELEPORT_BIT        0x00000004        // toggled every time the origin abruptly changes
  197. #define    EF_AWARD_EXCELLENT    0x00000008        // draw an excellent sprite
  198. #define    EF_BOUNCE            0x00000010        // for missiles
  199. #define    EF_BOUNCE_HALF        0x00000020        // for missiles
  200. #define    EF_AWARD_GAUNTLET    0x00000040        // draw a gauntlet sprite
  201. #define    EF_NODRAW            0x00000080        // may have an event, but no model (unspawned items)
  202. #define    EF_FIRING            0x00000100        // for lightning gun
  203. #define    EF_MOVER_STOP        0x00000400        // will push otherwise
  204. #define    EF_TALK                0x00001000        // draw a talk balloon
  205. #define    EF_CONNECTION        0x00002000        // draw a connection trouble sprite
  206. #define    EF_VOTED            0x00004000        // already cast a vote
  207. #define    EF_AWARD_IMPRESSIVE    0x00008000        // draw an impressive sprite
  208.  
  209. typedef enum {
  210.     PW_NONE,
  211.  
  212.     PW_QUAD,
  213.     PW_BATTLESUIT,
  214.     PW_HASTE,
  215.     PW_INVIS,
  216.     PW_REGEN,
  217.     PW_FLIGHT,
  218.  
  219.     PW_REDFLAG,
  220.     PW_BLUEFLAG,
  221.     PW_BALL,
  222.  
  223.     PW_NUM_POWERUPS
  224. } powerup_t;
  225.  
  226. typedef enum {
  227.     HI_NONE,
  228.  
  229.     HI_TELEPORTER,
  230.     HI_MEDKIT,
  231.  
  232.     HI_NUM_HOLDABLE
  233. } holdable_t;
  234.  
  235. typedef enum {
  236.     WP_NONE,
  237.  
  238.     WP_GAUNTLET,
  239.     WP_MACHINEGUN,
  240.     WP_SHOTGUN,
  241.     WP_GRENADE_LAUNCHER,
  242.     WP_ROCKET_LAUNCHER,
  243.     WP_LIGHTNING,
  244.     WP_RAILGUN,
  245.     WP_PLASMAGUN,
  246.     WP_BFG,
  247.     WP_GRAPPLING_HOOK,
  248.  
  249.     WP_NUM_WEAPONS
  250. } weapon_t;
  251.  
  252.  
  253. // reward sounds
  254. typedef enum {
  255.     REWARD_BAD,
  256.  
  257.     REWARD_IMPRESSIVE,
  258.     REWARD_EXCELLENT,
  259.     REWARD_DENIED,
  260.     REWARD_GAUNTLET
  261. } reward_t;
  262.  
  263.  
  264. // entityState_t->event values
  265. // entity events are for effects that take place reletive
  266. // to an existing entities origin.  Very network efficient.
  267.  
  268. // two bits at the top of the entityState->event field
  269. // will be incremented with each change in the event so
  270. // that an identical event started twice in a row can
  271. // be distinguished.  And off the value with ~EV_EVENT_BITS
  272. // to retrieve the actual event number
  273. #define    EV_EVENT_BIT1        0x00000100
  274. #define    EV_EVENT_BIT2        0x00000200
  275. #define    EV_EVENT_BITS        (EV_EVENT_BIT1|EV_EVENT_BIT2)
  276.  
  277. typedef enum {
  278.     EV_NONE,
  279.  
  280.     EV_FOOTSTEP,
  281.     EV_FOOTSTEP_METAL,
  282.     EV_FOOTSPLASH,
  283.     EV_FOOTWADE,
  284.     EV_SWIM,
  285.  
  286.     EV_STEP_4,
  287.     EV_STEP_8,
  288.     EV_STEP_12,
  289.     EV_STEP_16,
  290.  
  291.     EV_FALL_SHORT,
  292.     EV_FALL_MEDIUM,
  293.     EV_FALL_FAR,
  294.  
  295.     EV_JUMP_PAD,            // boing sound at origin, jump sound on player
  296.  
  297.     EV_JUMP,
  298.     EV_WATER_TOUCH,    // foot touches
  299.     EV_WATER_LEAVE,    // foot leaves
  300.     EV_WATER_UNDER,    // head touches
  301.     EV_WATER_CLEAR,    // head leaves
  302.  
  303.     EV_ITEM_PICKUP,            // normal item pickups are predictable
  304.     EV_GLOBAL_ITEM_PICKUP,    // powerup / team sounds are broadcast to everyone
  305.  
  306.     EV_NOAMMO,
  307.     EV_CHANGE_WEAPON,
  308.     EV_FIRE_WEAPON,
  309.  
  310.     EV_USE_ITEM0,
  311.     EV_USE_ITEM1,
  312.     EV_USE_ITEM2,
  313.     EV_USE_ITEM3,
  314.     EV_USE_ITEM4,
  315.     EV_USE_ITEM5,
  316.     EV_USE_ITEM6,
  317.     EV_USE_ITEM7,
  318.     EV_USE_ITEM8,
  319.     EV_USE_ITEM9,
  320.     EV_USE_ITEM10,
  321.     EV_USE_ITEM11,
  322.     EV_USE_ITEM12,
  323.     EV_USE_ITEM13,
  324.     EV_USE_ITEM14,
  325.     EV_USE_ITEM15,
  326.  
  327.     EV_ITEM_RESPAWN,
  328.     EV_ITEM_POP,
  329.     EV_PLAYER_TELEPORT_IN,
  330.     EV_PLAYER_TELEPORT_OUT,
  331.  
  332.     EV_GRENADE_BOUNCE,        // eventParm will be the soundindex
  333.  
  334.     EV_GENERAL_SOUND,
  335.     EV_GLOBAL_SOUND,        // no attenuation
  336.  
  337.     EV_BULLET_HIT_FLESH,
  338.     EV_BULLET_HIT_WALL,
  339.  
  340.     EV_MISSILE_HIT,
  341.     EV_MISSILE_MISS,
  342.     EV_RAILTRAIL,
  343.     EV_SHOTGUN,
  344.     EV_BULLET,                // otherEntity is the shooter
  345.  
  346.     EV_PAIN,
  347.     EV_DEATH1,
  348.     EV_DEATH2,
  349.     EV_DEATH3,
  350.     EV_OBITUARY,
  351.  
  352.     EV_POWERUP_QUAD,
  353.     EV_POWERUP_BATTLESUIT,
  354.     EV_POWERUP_REGEN,
  355.  
  356.     EV_GIB_PLAYER,            // gib a previously living player
  357.  
  358.     EV_DEBUG_LINE,
  359.     EV_TAUNT
  360.  
  361. } entity_event_t;
  362.  
  363.  
  364. // animations
  365. typedef enum {
  366.     BOTH_DEATH1,
  367.     BOTH_DEAD1,
  368.     BOTH_DEATH2,
  369.     BOTH_DEAD2,
  370.     BOTH_DEATH3,
  371.     BOTH_DEAD3,
  372.  
  373.     TORSO_GESTURE,
  374.  
  375.     TORSO_ATTACK,
  376.     TORSO_ATTACK2,
  377.  
  378.     TORSO_DROP,
  379.     TORSO_RAISE,
  380.  
  381.     TORSO_STAND,
  382.     TORSO_STAND2,
  383.  
  384.     LEGS_WALKCR,
  385.     LEGS_WALK,
  386.     LEGS_RUN,
  387.     LEGS_BACK,
  388.     LEGS_SWIM,
  389.  
  390.     LEGS_JUMP,
  391.     LEGS_LAND,
  392.  
  393.     LEGS_JUMPB,
  394.     LEGS_LANDB,
  395.  
  396.     LEGS_IDLE,
  397.     LEGS_IDLECR,
  398.  
  399.     LEGS_TURN,
  400.  
  401.     MAX_ANIMATIONS
  402. } animNumber_t;
  403.  
  404.  
  405. typedef struct animation_s {
  406.     int        firstFrame;
  407.     int        numFrames;
  408.     int        loopFrames;            // 0 to numFrames
  409.     int        frameLerp;            // msec between frames
  410.     int        initialLerp;        // msec to get to first frame
  411. } animation_t;
  412.  
  413.  
  414. // flip the togglebit every time an animation
  415. // changes so a restart of the same anim can be detected
  416. #define    ANIM_TOGGLEBIT        128
  417.  
  418.  
  419. typedef enum {
  420.     TEAM_FREE,
  421.     TEAM_RED,
  422.     TEAM_BLUE,
  423.     TEAM_SPECTATOR,
  424.  
  425.     TEAM_NUM_TEAMS
  426. } team_t;
  427.  
  428. // Time between location updates
  429. #define TEAM_LOCATION_UPDATE_TIME        1000
  430.  
  431. // How many players on the overlay
  432. #define TEAM_MAXOVERLAY        8
  433.  
  434. // means of death
  435. typedef enum {
  436.     MOD_UNKNOWN,
  437.     MOD_SHOTGUN,
  438.     MOD_GAUNTLET,
  439.     MOD_MACHINEGUN,
  440.     MOD_GRENADE,
  441.     MOD_GRENADE_SPLASH,
  442.     MOD_ROCKET,
  443.     MOD_ROCKET_SPLASH,
  444.     MOD_PLASMA,
  445.     MOD_PLASMA_SPLASH,
  446.     MOD_RAILGUN,
  447.     MOD_LIGHTNING,
  448.     MOD_BFG,
  449.     MOD_BFG_SPLASH,
  450.     MOD_WATER,
  451.     MOD_SLIME,
  452.     MOD_LAVA,
  453.     MOD_CRUSH,
  454.     MOD_TELEFRAG,
  455.     MOD_FALLING,
  456.     MOD_SUICIDE,
  457.     MOD_TARGET_LASER,
  458.     MOD_TRIGGER_HURT,
  459.     MOD_GRAPPLE
  460. } meansOfDeath_t;
  461.  
  462.  
  463. //---------------------------------------------------------
  464.  
  465. // gitem_t->type
  466. typedef enum {
  467.     IT_BAD,
  468.     IT_WEAPON,                // EFX: rotate + upscale + minlight
  469.     IT_AMMO,                // EFX: rotate
  470.     IT_ARMOR,                // EFX: rotate + minlight
  471.     IT_HEALTH,                // EFX: static external sphere + rotating internal
  472.     IT_POWERUP,                // instant on, timer based
  473.                             // EFX: rotate + external ring that rotates
  474.     IT_HOLDABLE,            // single use, holdable item
  475.                             // EFX: rotate + bob
  476.     IT_TEAM
  477. } itemType_t;
  478.  
  479. #define MAX_ITEM_MODELS 4
  480.  
  481. typedef struct gitem_s {
  482.     char        *classname;    // spawning name
  483.     char        *pickup_sound;
  484.     char        *world_model[MAX_ITEM_MODELS];
  485.  
  486.     char        *icon;
  487.     char        *pickup_name;    // for printing on pickup
  488.  
  489.     int            quantity;        // for ammo how much, or duration of powerup
  490.     itemType_t  giType;            // IT_* flags
  491.  
  492.     int            giTag;
  493.  
  494.     char        *precaches;        // string of all models and images this item will use
  495.     char        *sounds;        // string of all sounds this item will use
  496. } gitem_t;
  497.  
  498. // included in both the game dll and the client
  499. extern    gitem_t    bg_itemlist[];
  500. extern    int        bg_numItems;
  501.  
  502. gitem_t    *BG_FindItem( const char *pickupName );
  503. gitem_t    *BG_FindItemForWeapon( weapon_t weapon );
  504. gitem_t    *BG_FindItemForPowerup( powerup_t pw );
  505. gitem_t    *BG_FindItemForHoldable( holdable_t pw );
  506. #define    ITEM_INDEX(x) ((x)-bg_itemlist)
  507.  
  508. qboolean    BG_CanItemBeGrabbed( const entityState_t *ent, const playerState_t *ps );
  509.  
  510.  
  511. // g_dmflags->integer flags
  512. #define    DF_NO_FALLING            8
  513. #define DF_FIXED_FOV            16
  514. #define    DF_NO_FOOTSTEPS            32
  515.  
  516. // content masks
  517. #define    MASK_ALL                (-1)
  518. #define    MASK_SOLID                (CONTENTS_SOLID)
  519. #define    MASK_PLAYERSOLID        (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_BODY)
  520. #define    MASK_DEADSOLID            (CONTENTS_SOLID|CONTENTS_PLAYERCLIP)
  521. #define    MASK_WATER                (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)
  522. #define    MASK_OPAQUE                (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)
  523. #define    MASK_SHOT                (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE)
  524.  
  525.  
  526. //
  527. // entityState_t->eType
  528. //
  529. typedef enum {
  530.     ET_GENERAL,
  531.     ET_PLAYER,
  532.     ET_ITEM,
  533.     ET_MISSILE,
  534.     ET_MOVER,
  535.     ET_BEAM,
  536.     ET_PORTAL,
  537.     ET_SPEAKER,
  538.     ET_PUSH_TRIGGER,
  539.     ET_TELEPORT_TRIGGER,
  540.     ET_INVISIBLE,
  541.     ET_GRAPPLE,                // grapple hooked on wall
  542.  
  543.     ET_EVENTS                // any of the EV_* events can be added freestanding
  544.                             // by setting eType to ET_EVENTS + eventNum
  545.                             // this avoids having to set eFlags and eventNum
  546. } entityType_t;
  547.  
  548.  
  549.  
  550. void    BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result );
  551. void    BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t result );
  552.  
  553. void    BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps );
  554.  
  555. void    BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap );
  556.  
  557. qboolean    BG_PlayerTouchesItem( playerState_t *ps, entityState_t *item, int atTime );
  558.  
  559.  
  560. #define ARENAS_PER_TIER        4
  561. #define MAX_ARENAS            1024
  562. #define    MAX_ARENAS_TEXT        8192
  563.  
  564. #define MAX_BOTS            1024
  565. #define MAX_BOTS_TEXT        8192
  566.